<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="webjars/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>

</body>
<script>
    var url = "localhost:7000";
    var timeout =60000;
    $(function () {
        req("service_func",{"k":"值"},"handler");
    });

    function req(service,inParam,func){
        var
            inData=
                {serviceName: service,
                    inParam: inParam};
        console.log(inData);
        $.ajax({
            type: "POST",
            timeout: timeout,
            async: true,
            data: inData,
            dataType: 'json',
            url: "http://" + url + "/reqJson",

            success: function (data) {

                console.log(service + "|" + func + "outBody === " );
                console.log(data);
                window[func](data);
            },
            error: function (data) {
                console.log(service + "|" + func + "|out：" );
                console.log(data);
                alert("调用服务失败，请联系管理员！");
            }
        });
    }
    function handler(data) {
        console.log(data);
    }

</script>
</html>